package com.coco.seck.controller;

import com.coco.common.result.CommonResponse;
import com.coco.common.result.ResultData;
import com.coco.seck.feign.GoodsFeignService;
import com.coco.seck.pojo.TbDeploy;
import com.coco.seck.service.DeployService;
import com.coco.seck.vo.DeployVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author HanSama
 * @date 2021年07月15日 22:37
 */
@RestController
@RequestMapping("/seck/deploy")
public class DeployController {

    @Autowired
    private DeployService deployService;

    @Autowired
    private GoodsFeignService goodsFeignService;


    @RequestMapping("/findAllGoods")
    public CommonResponse findAllGoods() {
        return goodsFeignService.findAll();
    }

    /**
     * 查询全部
     *
     * @return java.util.List<com.coco.seck.pojo.TbDeploy>
     * @author HanSama
     * @date 2021/7/16 17:25
     */
    @RequestMapping("/findAll")
    public List<TbDeploy> findAll() {
        return deployService.findAll();
    }

    /**
     * 分页模糊 显示逻辑未删除数据
     *
     * @param deployVo
     * @author HanSama
     * @date 2021/7/16 17:26
     */
    @RequestMapping("/findDeployList")
    public ResultData findDeployList(@RequestBody DeployVo deployVo) {

        return deployService.findDeployList(deployVo);
    }

    /**
     * 添加
     *
     * @param deploy
     * @return null
     * @author HanSama
     * @date 2021/7/16 17:33
     */
    @RequestMapping("/addDeploy")
    public void addDeploy(@RequestBody TbDeploy deploy) {
        deployService.addDeploy(deploy);
    }

    /**
     * 修改
     *
     * @param deploy
     * @author HanSama
     * @date 2021/7/18 10:00
     */
    @RequestMapping("/updateDeploy")
    public void updateDeploy(@RequestBody TbDeploy deploy) {
        deployService.updateDeploy(deploy);
    }

    /**
     * 通过id逻辑删除
     *
     * @param id
     * @author HanSama
     * @date 2021/7/18 10:03
     */
    @DeleteMapping("/deleteById/{id}")
    public void deleteById(@PathVariable Long id) {
        deployService.deleteById(id);
    }

    /**
     * 修改状态
     *
     * @param id
     * @param status
     */
    @PutMapping("/updateStatus/{id}/{status}")
    public void updateStatus(@PathVariable Long id, @PathVariable Integer status) {
        try {
            deployService.updateStatus(id, status);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询单条
     *
     * @param id
     * @return
     */
    @GetMapping("/selectById/{id}")
    public TbDeploy selectById(@PathVariable Long id) {
        return deployService.selectById(id);
    }


}
